package com.example.lp.lpuicore.views.view;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import com.example.lp.lpuicore.R;

import java.util.LinkedList;
import java.util.List;
/**
 * 交错滑动冲突
 * 外部拦截法
 * */
public class HVActivity extends AppCompatActivity {
    private Context context;
    private HorizontalEx horizontalEx;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hv);
        context=this;
        horizontalEx=findViewById(R.id.hr_ex);
        List<String> data=new LinkedList<>();
        int count=50;
        for (int i = 0; i < count; i++) {
            data.add(i+"");
        }
        showOutHVData(data,data,data);
    }


    private void showOutHVData(List<String> data1, List<String> data2, List<String> data3) {
        ListView listView1 = new ListView(context);
        ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, data1);
        listView1.setAdapter(adapter1);

        ListView listView2 = new ListView(context);
        ArrayAdapter<String> adapter2 = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, data2);
        listView2.setAdapter(adapter2);

        ListView listView3 = new ListView(context);
        ArrayAdapter<String> adapter3 = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1, data3);
        listView3.setAdapter(adapter3);

        ViewGroup.LayoutParams params
                = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);

        horizontalEx.addView(listView1, params);
        horizontalEx.addView(listView2, params);
        horizontalEx.addView(listView3, params);
    }
}
